package weather;

import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

/**
 *
 * @author Sebas
 */
public class DewPointDisplay implements Observer, DisplayElement {

    private float temperature;
    private float humidity;
    Observable observable;

    public DewPointDisplay(Observable observable) {
        this.observable = observable;
        observable.addObserver(this);
    }

    public void update(Observable obs, Object arg) {
        if (obs instanceof WeatherData) {
            WeatherData weather = (WeatherData) obs;
            this.temperature = (weather.getTemperature());
            this.humidity = (weather.getHumidity());
            display();
        }
    }

    private double getDewPoint() {
        return ((Math.pow((humidity / 100), 1 / 8)) * (110 + temperature)) - 110;
    }

    public void display() {
        System.out.println("** DewPoint: " + this.getDewPoint() + "C degrees.");
        System.out.println();
        System.out.println();
    }
}